home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / wb / czesc_4 / vark15 / utils a-o / kick2file.lha / kick2file / Kick2File.c < prev    next >
C/C++ Source or Header  |  1996-06-11  |  2KB  |  91 lines

  1.  
  2. // Includes
  3. #include <exec/types.h>
  4. #include <pragma/dos_lib.h>
  5. #include <dos/dos.h>
  6. #include <iostream.h>
  7. #include <stdlib.h>
  8.  
  9.  
  10. // Konstanten
  11. #define SMALLMAGIC 0x11114ef9
  12. #define SMALLROM   0x00040000
  13. #define BIGMAGIC   0x11144ef9
  14. #define BIGROM     0x00080000
  15.  
  16.  
  17. // Strukturen
  18. struct romfileheader
  19. {
  20.   ULONG alwaysnil;
  21.   ULONG romsize;
  22. };
  23.  
  24.  
  25. // globale Variablen
  26. char *versi = "$VER: Kick2File 1.0 (11-Jun-1996) © by Maik \"BLiZZeR\" Schreiber [FREEWARE]";
  27.  
  28.  
  29. // Programm
  30. int main(int argc, char *argv[])
  31. {
  32.   if (argc != 2)
  33.     cout << "Usage: Kick2File <filename>\n";
  34.   else if (((char *) argv[1])[0] == '?')
  35.     cout << "Usage: Kick2File <filename>\n";
  36.   else
  37.   {
  38.     int    ret  = RETURN_OK;
  39.     ULONG *base = (ULONG *) 0x00f80000,
  40.            size;
  41.  
  42.     if (base[0] != BIGMAGIC)
  43.       base = (ULONG *) 0x00fc0000;
  44.  
  45.     switch (base[0])
  46.     {
  47.       case SMALLMAGIC:
  48.         size = SMALLROM;
  49.         break;
  50.       case BIGMAGIC:
  51.         size = BIGROM;
  52.         break;
  53.       default:
  54.         size = NULL;
  55.     };
  56.     if (size)
  57.     {
  58.       struct romfileheader rfh = {NULL, size};
  59.       BPTR   handle;
  60.       ULONG  len;
  61.  
  62.       cout << "\033[1mKick2File 1.0 - Copyright © 11-Jun-1996 by Maik Schreiber [FREEWARE]\033[0m\n\n\
  63. Writing ROM data (" << sizeof(struct romfileheader) + size << " Bytes)...\n";
  64.  
  65.       if (handle = Open(argv[1], MODE_NEWFILE))
  66.       {
  67.         len = Write(handle, &rfh, sizeof(struct romfileheader));
  68.         len += Write(handle, base, size);
  69.         Close(handle);
  70.         if (len != (sizeof(struct romfileheader) + size))
  71.         {
  72.           cout << "\n\033[1mCouldn't write ROM data!\033[0m\n";
  73.           ret = RETURN_FAIL;
  74.         };
  75.       };
  76.       else
  77.       {
  78.         cout << "\n\033[1mCouldn't open file!\033[0m\n";
  79.         ret = RETURN_FAIL;
  80.       };
  81.     };
  82.     else
  83.     {
  84.       cout << "\n\033[1;33mUnknown ROM size!\033[0m\n";
  85.       ret = RETURN_FAIL;
  86.     };
  87.     exit(ret);
  88.   };
  89. };
  90.  
  91.